package com.qys.livesMall.app.user.model.enums;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * Created by IntelliJ IDEA.
 * User: dp
 * Date: 2023/04/26
 * Time: 14:50
 * DESCRIPTION: 性别
 */
@AllArgsConstructor
@Getter
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum UserGenderEnum {

    WOMAN(0, "女"),

    MAN(1, "男"),

    UNKNOWN(2, "未知"),
    ;

    private final int code;

    private final String name;

    public static UserGenderEnum getEnum(Integer code) {
        for (UserGenderEnum genderEnum : UserGenderEnum.values()) {
            if (genderEnum.getCode() == code) {
                return genderEnum;
            }
        }
        return null;
    }
}
